<template>
	<div class="up-wrap">
		 <a-upload
		    v-model:file-list="fileList"
		    name="files"
		    list-type="picture"
		    class="avatar-uploader"
			:capture="null"
		    multiple
		    :action="fileurl"
		    :headers="headers"
		    @change="upChange"
		  >
		   
		    <div>
		     
		      <div class="ant-upload-text">点击上传</div>
		    </div>
		  </a-upload>
	</div>
	
	
	
	<div class="sub-wrap">
		<a-button @click="subdata" type="primary">提交</a-button>
	</div>
	
</template>

<script>

import {

assetapiapplycommonsubmitpictur} from '../../../api/manpart.js'
import { computed,ref, defineComponent,reactive,onMounted } from 'vue';
import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue';
import {useRouter} from 'vue-router'

export default defineComponent({
	components: {
	    LoadingOutlined,
	    PlusOutlined,
	  },
  setup() {
	  const $route=useRouter()
	  let keyword=$route.currentRoute.value.query.keyword
	  let token=$route.currentRoute.value.query.token
	  localStorage.setItem('ht-new-fixed-token',token)
    let fileList=ref([])
	let headers={
		Authorization:token
	}
	let fileurl='http://www.jxsks.com:8686/canteen/api/assetways/uploadFiles'
	const upChange = (info) => {
	     if (info.file.status !== 'uploading') {
	       
	     }
	     if (info.file.status === 'done') {
				globalVar.Message.success('上传成功')
				
				
	       
	     } else if (info.file.status === 'error') {
	       globalVar.Message.error(`上传失败`);
	     }
	   };
	   
	   onMounted(()=>{
		  
		    

	   })
	   
	   console.log(keyword)
	   
	const subdata=()=>{
		
		let message=[]
		let id=keyword
		for(let i=0;i<fileList.value.length;i++){
			message.push(fileList.value[i].response.object)
			
		}
		assetapiapplycommonsubmitpictur({message:message.join(','),id}).then(e=>{
			if(e.code==1){
				globalVar.Message.success('上传成功')
			}
		}).catch(err=>{
			console.log(err)
		})
	}
    return {
		subdata,
		upChange,
		fileurl,
		fileList,
		headers
    };
  }
});
</script>
<style>
	.avatar-uploader{
		width:auto;
	}
	.avatar-uploader .ant-upload-select{
		margin:0 auto;
		border:1px blue dashed;
		display:flex;
		justify-content: center;
		align-items: center;
		height:100px;
		width:100px;
		margin-bottom:50px;
	}
</style>
<style scoped>
	.sub-wrap{
		position:fixed;
		width:100%;
		bottom:100px;
		left:0;
		display:flex;
		justify-content: center;
		align-items: center;
	}
	.up-wrap{
		padding-top:40px;
		display:flex;
		justify-content: center;
		align-items: center;
	}
</style>